package com.zust.data.util.demo.prime;

/**
 * @author senselyan
 * @Description: ${todo}
 * @date 2018/4/19 14:29
 */
public class FindPrime {
    public static void main(String[] args) {
        for (long i = 2; i < 30000; i++) {
            if (isPrime(i)) {
                System.out.print(i + ", ");
            }
        }
    }

    private static boolean isPrime(long flag) {
        if (flag != 2 && flag % 2 == 0 ) return false;
        Double diviNum = Math.sqrt(flag);
        for (int i = 3; i <= diviNum; i += 2) {
            if (flag % i == 0) {
                return false;
            }
        }
        return true;
    }
}
